import { CardEvent } from '../../api/CardEvent';
import { Room } from '../../api/Room';
import { Card } from '../base/Card';

export class TeaHorseTrade extends Card {
	title(room: Room, user: string): string {
		return '茶马互市';
	}

	desc(room: Room, user: string): string {
		var money = this.costMoney(room, user);
		return `获得指定部门的1张手牌，并给予该部门${money}铜钱。`;
	}

	use(room: Room, user: string, target: string): void {
		var dept = room.getDept(target);
		if (!dept) return;

		var index = Math.floor(Math.random() * dept.handCards.length);
		var card = dept.handCards[index];
		if (card.cardId == 'NextTurn') return;
		CardEvent.addCard(room, user, card);
		CardEvent.destroyHandCard(room, target, index);
		var money = this.costMoney(room, user);
		dept.addDeptDataValue('money', money);
	}

    target(room: Room, user: string): string {
        return 'all';
    }
}
